import { Map, fromJS } from 'immutable';
import { AnyAction } from 'redux';
import {
    SYNC_WORKER,
    SYNC_WORKER_LOADING
} from './constants';

const initialState = fromJS({
    workers: null,
    loading_workers: false
});

export default (state: Map<string, any> = initialState, action: AnyAction) => {
    switch (action.type) {
        case SYNC_WORKER:
            return state
                .set('workers', action.payload);
        case SYNC_WORKER_LOADING:
            return state
                .set('loading_workers', action.payload);
        default:
            return state;
    }
};
